package com.xpgk.mvc.productSet;

import java.util.List;

import javax.xml.crypto.Data;

import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.xpgk.annotation.Table;
import com.xpgk.mvc.base.BaseModel;
import com.xpgk.mvc.codeSet.Code;

/**
 * 产品
 */
@SuppressWarnings("unused")
@Table(tableName = ProductExperience.table_name)
public class ProductExperience extends BaseModel<ProductExperience> {

	private static final long serialVersionUID = 3629568734943847604L;

	private static final Log log = Log.getLog(ProductExperience.class);

	public static final ProductExperience dao = new ProductExperience().dao();

	/**
	 * 表名称
	 */
	public static final String table_name = "sb_product_experience";


	
	/**
	 * 字段描述：主键 字段类型：character varying 长度：32
	 */
	public static final String column_ids = "ids";
	/**
	 * 字段描述：产品ids：character varying 长度：32
	 */
	public static final String column_productIds = "productIds";
	/**
	 * 字段描述：部位ids：character varying 长度：32
	 */
	public static final String column_partIds = "partIds";
	/**
	 * 字段描述：经验值 字段类型：float 长度：3
	 */
	public static final String column_experience = "experience";
	
	/**
	 * 字段描述：该条数据添加人员is  字段类型：character varying 长度：32
	 */
	public static final String column_createId = "createId";
	/**
	 * 字段描述：该条数据添加时间  字段类型：datetime 长度：0
	 */
	public static final String column_createDate = "createDate";
	/**
	 * 字段描述：该条数据更新人员id  字段类型：character varying 长度：100
	 */
	public static final String column_updateId = "updateId";
	/**
	 * 字段描述：该条数据更新时间  字段类型：datetime 长度：0
	 */
	public static final String column_updateDate = "updateDate";
	
	public static final String column_dataStatus = "dataStatus";
	public static final String column_orgId = "orgId";
	
	
	/**
	 * 通过产品ids查找经验值
	 * @param productIds
	 * @return
	 */
	public List<Record> findByProIds(String productIds){
		String sql = "SELECT "
				+ "sc.ids partIds,sc. NAME,spe.experience,spe.ids "
				+ "FROM "
				+ "sys_code sc "
				+ "LEFT JOIN "
				+ "(SELECT ids, partIds, experience FROM sb_product_experience WHERE productIds = ?) spe "
				+ "on "
				+ "sc.ids = spe.partIds "
				+ "WHERE "
				+ "sc.parentids = ?";
		return Db.find(sql, productIds, Code.fwbw_ids);
	}

}
